/**
 * Copyright (C) 2012 Eduard Sedov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.es.function.impl;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import org.es.function.MethodFilter;

/**
 * An implementation of {@link MethodFilter} for all methods of {@link Object} class.
 * 
 * @author ESEDO
 */
public class ObjectMethodFilter implements MethodFilter {

    /** static instance */
    private static ObjectMethodFilter instance = new ObjectMethodFilter();
    /** holder of all object methods */
    private static Set<Method> methods = new HashSet();

    static {
        methods.addAll(Arrays.asList(Object.class.getMethods()));
    }

    /**
     * Returns the static instance of {@link ObjectMethodFilter}.
     * @return the static instance
     */
    public static ObjectMethodFilter get() {
        return instance;
    }

    /**
     * {@inheritDoc}
     */
    public boolean accept(Method method) {
        return methods.contains(method) == false;
    }
}
